/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-05-03
 * Time: 10:17
 */
public class TestDemo {
    //递归实现斐波那契数列
    //1 1 2 3 5 8 13 21 34 55 89
    public static void main1(String[] args) {
        int n = 39;//求第39个斐波那契数
        int ret = fabonacci(n);
        System.out.println(ret);
        System.out.println("n = 3被计算的次数:"+count);
    }
    public static int count = 0;
    public static int fabonacci(int n){
        if(n==1 || n==2){
            return 1;
        }else {
            if(n == 3){
                count++;
            }
            return fabonacci(n-1)+fabonacci(n-2);
        }
    }
}

